
class LocalCach {
  // 缓存到本地
  cachLocal(key:string, value: any) {
    window.localStorage.setItem(key, JSON.stringify(value))
  }

  // 获取缓存
  getCach(key:string){
    const value = window.localStorage.getItem(key)
    if (value) {
      return JSON.parse(value)
    }
  }

  // 删除缓存
  deleteCach(key:string) {
    window.localStorage.removeItem(key)
  }

  // 清空缓存
  clearCach() {
    window.localStorage.clear()
  }

}

export default new LocalCach()
